<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function getEndTime(val) {
      var start = +new Date(),
        end = +new Date(val)

      var diff = parseInt((end - start) / 1000)

      // 131  2分 11秒
      // 60 * 60 * 24 = 86400

      // var d = diff / (60 * 60 * 24)

      // diff / (3600) =   多少个小时  % 24

      // diff / 60 = 多少个分钟 % 60 = 剩余的 分钟

      var d = parseInt(diff / 60 / 60 / 24)
      var h = parseInt(diff / 60 / 60 % 24)
      var m = parseInt(diff / 60 % 60)
      var s = parseInt(diff % 60)

      var str = d + '天' + h + '时' + m + '分' + s + '秒'

      return str
    }

    var result = getEndTime('2021-8-25 20:00:00')

    console.log( result )

  </script>
</body>
</html>